#!/usr/bin/env python
import PCF8591 as ADC
import RPi.GPIO as GPIO
import time
import math
DO = 22
GPIO.setmode(GPIO.BCM)
def setup():
    ADC.setup(0x48)
    GPIO.setup(DO, GPIO.IN)

def loop():
    status = 1
    count = 0
    while True:
        print("smoke = ",ADC.read(0))  # 有烟雾时，该值增大
        DOS = GPIO.input(DO)
        print('DOS = ', DOS)
        # 无烟雾时为高电平，tmp=1,打印safe，有烟雾时为低电平，打印Danger Gas！
        time.sleep(2)

if __name__ == 'main':
    setup()
    loop()